// $ANTLR 3.1.3 Mar 18, 2009 10:09:25 XHTML2CSV_raw.g 2009-10-13 15:15:32

import org.antlr.runtime.*;
import java.util.Stack;
import java.util.List;
import java.util.ArrayList;

public class XHTML2CSV_rawParser extends Parser {
    public static final String[] tokenNames = new String[] {
        "<invalid>", "<EOR>", "<DOWN>", "<UP>", "CELLULEG", "CELLULED", "LIGNEG", "LIGNED", "TABLED", "TABLEALIGN", "BORDER", "ENTIER", "FINBALISE", "GUILLEMET", "POS", "CHAINE", "WHITESPACE"
    };
    public static final int LIGNED=7;
    public static final int GUILLEMET=13;
    public static final int LIGNEG=6;
    public static final int POS=14;
    public static final int ENTIER=11;
    public static final int CELLULEG=4;
    public static final int TABLED=8;
    public static final int CELLULED=5;
    public static final int WHITESPACE=16;
    public static final int TABLEALIGN=9;
    public static final int CHAINE=15;
    public static final int EOF=-1;
    public static final int FINBALISE=12;
    public static final int BORDER=10;

    // delegates
    // delegators


        public XHTML2CSV_rawParser(TokenStream input) {
            this(input, new RecognizerSharedState());
        }
        public XHTML2CSV_rawParser(TokenStream input, RecognizerSharedState state) {
            super(input, state);
             
        }
        

    public String[] getTokenNames() { return XHTML2CSV_rawParser.tokenNames; }
    public String getGrammarFileName() { return "XHTML2CSV_raw.g"; }


    	public static void main(String [] args) throws Exception {

    		XHTML2CSV_rawLexer lex = new XHTML2CSV_rawLexer(new ANTLRFileStream(args[0]));	// create lexer to read the file specified from command line (i.e., first argument, e.g., java Main test1.xhtml)
    		CommonTokenStream tokens = new CommonTokenStream(lex);					// transform it into a token stream
    		XHTML2CSV_rawParser parser = new XHTML2CSV_rawParser(tokens);					// create the parser that reads from the token stream
    	
    		try {
    			String s = parser.balise_table();// (try to) parse a given rule specified in the parser file, e.g. cellule
                System.out.println(s);

    		} catch (RecognitionException e)  {
    			e.printStackTrace();
    		}
    	}



    // $ANTLR start "balise_table"
    // XHTML2CSV_raw.g:33:1: balise_table returns [String csv] : TABLEALIGN ( position_table ) BORDER ENTIER FINBALISE m= milieu TABLED ;
    public final String balise_table() throws RecognitionException {
        String csv = null;

        String m = null;


        try {
            // XHTML2CSV_raw.g:33:34: ( TABLEALIGN ( position_table ) BORDER ENTIER FINBALISE m= milieu TABLED )
            // XHTML2CSV_raw.g:33:36: TABLEALIGN ( position_table ) BORDER ENTIER FINBALISE m= milieu TABLED
            {
            match(input,TABLEALIGN,FOLLOW_TABLEALIGN_in_balise_table87); 
            // XHTML2CSV_raw.g:33:47: ( position_table )
            // XHTML2CSV_raw.g:33:49: position_table
            {
            pushFollow(FOLLOW_position_table_in_balise_table91);
            position_table();

            state._fsp--;


            }

            match(input,BORDER,FOLLOW_BORDER_in_balise_table95); 
            match(input,ENTIER,FOLLOW_ENTIER_in_balise_table97); 
            match(input,FINBALISE,FOLLOW_FINBALISE_in_balise_table99); 
            pushFollow(FOLLOW_milieu_in_balise_table103);
            m=milieu();

            state._fsp--;

            match(input,TABLED,FOLLOW_TABLED_in_balise_table105); 
            csv = m;

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return csv;
    }
    // $ANTLR end "balise_table"


    // $ANTLR start "position_table"
    // XHTML2CSV_raw.g:35:1: position_table : GUILLEMET POS GUILLEMET ;
    public final void position_table() throws RecognitionException {
        try {
            // XHTML2CSV_raw.g:35:16: ( GUILLEMET POS GUILLEMET )
            // XHTML2CSV_raw.g:35:18: GUILLEMET POS GUILLEMET
            {
            match(input,GUILLEMET,FOLLOW_GUILLEMET_in_position_table116); 
            match(input,POS,FOLLOW_POS_in_position_table118); 
            match(input,GUILLEMET,FOLLOW_GUILLEMET_in_position_table120); 

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
    // $ANTLR end "position_table"


    // $ANTLR start "milieu"
    // XHTML2CSV_raw.g:37:1: milieu returns [String csv] : l= ldlg m= milieu2 ;
    public final String milieu() throws RecognitionException {
        String csv = null;

        String l = null;

        String m = null;


        try {
            // XHTML2CSV_raw.g:37:28: (l= ldlg m= milieu2 )
            // XHTML2CSV_raw.g:37:31: l= ldlg m= milieu2
            {
            pushFollow(FOLLOW_ldlg_in_milieu134);
            l=ldlg();

            state._fsp--;

            pushFollow(FOLLOW_milieu2_in_milieu138);
            m=milieu2();

            state._fsp--;

            csv = l + "\n" + m;

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return csv;
    }
    // $ANTLR end "milieu"


    // $ANTLR start "milieu2"
    // XHTML2CSV_raw.g:39:1: milieu2 returns [String csv] : (l= ldlg m= milieu2 | );
    public final String milieu2() throws RecognitionException {
        String csv = null;

        String l = null;

        String m = null;


        try {
            // XHTML2CSV_raw.g:39:29: (l= ldlg m= milieu2 | )
            int alt1=2;
            int LA1_0 = input.LA(1);

            if ( (LA1_0==LIGNEG) ) {
                alt1=1;
            }
            else if ( (LA1_0==TABLED) ) {
                alt1=2;
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("", 1, 0, input);

                throw nvae;
            }
            switch (alt1) {
                case 1 :
                    // XHTML2CSV_raw.g:39:31: l= ldlg m= milieu2
                    {
                    pushFollow(FOLLOW_ldlg_in_milieu2155);
                    l=ldlg();

                    state._fsp--;

                    pushFollow(FOLLOW_milieu2_in_milieu2159);
                    m=milieu2();

                    state._fsp--;

                    csv = l + "\n" + m;

                    }
                    break;
                case 2 :
                    // XHTML2CSV_raw.g:39:83: 
                    {
                    csv = "";

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return csv;
    }
    // $ANTLR end "milieu2"


    // $ANTLR start "ldlg"
    // XHTML2CSV_raw.g:41:1: ldlg returns [String csv] : LIGNEG e= entre LIGNED ;
    public final String ldlg() throws RecognitionException {
        String csv = null;

        String e = null;


        try {
            // XHTML2CSV_raw.g:41:26: ( LIGNEG e= entre LIGNED )
            // XHTML2CSV_raw.g:41:28: LIGNEG e= entre LIGNED
            {
            match(input,LIGNEG,FOLLOW_LIGNEG_in_ldlg176); 
            pushFollow(FOLLOW_entre_in_ldlg180);
            e=entre();

            state._fsp--;

            match(input,LIGNED,FOLLOW_LIGNED_in_ldlg182); 
            csv = e;

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return csv;
    }
    // $ANTLR end "ldlg"


    // $ANTLR start "entre"
    // XHTML2CSV_raw.g:43:1: entre returns [String csv] : (c= cellule e= entre | c= cellule );
    public final String entre() throws RecognitionException {
        String csv = null;

        String c = null;

        String e = null;


        try {
            // XHTML2CSV_raw.g:43:27: (c= cellule e= entre | c= cellule )
            int alt2=2;
            int LA2_0 = input.LA(1);

            if ( (LA2_0==CELLULEG) ) {
                int LA2_1 = input.LA(2);

                if ( (LA2_1==CHAINE) ) {
                    int LA2_2 = input.LA(3);

                    if ( (LA2_2==CELLULED) ) {
                        int LA2_3 = input.LA(4);

                        if ( (LA2_3==CELLULEG) ) {
                            alt2=1;
                        }
                        else if ( (LA2_3==LIGNED) ) {
                            alt2=2;
                        }
                        else {
                            NoViableAltException nvae =
                                new NoViableAltException("", 2, 3, input);

                            throw nvae;
                        }
                    }
                    else {
                        NoViableAltException nvae =
                            new NoViableAltException("", 2, 2, input);

                        throw nvae;
                    }
                }
                else {
                    NoViableAltException nvae =
                        new NoViableAltException("", 2, 1, input);

                    throw nvae;
                }
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("", 2, 0, input);

                throw nvae;
            }
            switch (alt2) {
                case 1 :
                    // XHTML2CSV_raw.g:43:29: c= cellule e= entre
                    {
                    pushFollow(FOLLOW_cellule_in_entre198);
                    c=cellule();

                    state._fsp--;

                    pushFollow(FOLLOW_entre_in_entre202);
                    e=entre();

                    state._fsp--;

                    csv = c + ", " + e;

                    }
                    break;
                case 2 :
                    // XHTML2CSV_raw.g:43:82: c= cellule
                    {
                    pushFollow(FOLLOW_cellule_in_entre210);
                    c=cellule();

                    state._fsp--;

                    csv = c ;

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return csv;
    }
    // $ANTLR end "entre"


    // $ANTLR start "cellule"
    // XHTML2CSV_raw.g:45:1: cellule returns [String csv] : CELLULEG CHAINE CELLULED ;
    public final String cellule() throws RecognitionException {
        String csv = null;

        Token CHAINE1=null;

        try {
            // XHTML2CSV_raw.g:45:30: ( CELLULEG CHAINE CELLULED )
            // XHTML2CSV_raw.g:45:32: CELLULEG CHAINE CELLULED
            {
            match(input,CELLULEG,FOLLOW_CELLULEG_in_cellule226); 
            CHAINE1=(Token)match(input,CHAINE,FOLLOW_CHAINE_in_cellule228); 
            match(input,CELLULED,FOLLOW_CELLULED_in_cellule230); 
            csv = "\"" + (CHAINE1!=null?CHAINE1.getText():null);

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return csv;
    }
    // $ANTLR end "cellule"

    // Delegated rules


 

    public static final BitSet FOLLOW_TABLEALIGN_in_balise_table87 = new BitSet(new long[]{0x0000000000002000L});
    public static final BitSet FOLLOW_position_table_in_balise_table91 = new BitSet(new long[]{0x0000000000000400L});
    public static final BitSet FOLLOW_BORDER_in_balise_table95 = new BitSet(new long[]{0x0000000000000800L});
    public static final BitSet FOLLOW_ENTIER_in_balise_table97 = new BitSet(new long[]{0x0000000000001000L});
    public static final BitSet FOLLOW_FINBALISE_in_balise_table99 = new BitSet(new long[]{0x0000000000000040L});
    public static final BitSet FOLLOW_milieu_in_balise_table103 = new BitSet(new long[]{0x0000000000000100L});
    public static final BitSet FOLLOW_TABLED_in_balise_table105 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_GUILLEMET_in_position_table116 = new BitSet(new long[]{0x0000000000004000L});
    public static final BitSet FOLLOW_POS_in_position_table118 = new BitSet(new long[]{0x0000000000002000L});
    public static final BitSet FOLLOW_GUILLEMET_in_position_table120 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_ldlg_in_milieu134 = new BitSet(new long[]{0x0000000000000040L});
    public static final BitSet FOLLOW_milieu2_in_milieu138 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_ldlg_in_milieu2155 = new BitSet(new long[]{0x0000000000000040L});
    public static final BitSet FOLLOW_milieu2_in_milieu2159 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_LIGNEG_in_ldlg176 = new BitSet(new long[]{0x0000000000000010L});
    public static final BitSet FOLLOW_entre_in_ldlg180 = new BitSet(new long[]{0x0000000000000080L});
    public static final BitSet FOLLOW_LIGNED_in_ldlg182 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_cellule_in_entre198 = new BitSet(new long[]{0x0000000000000010L});
    public static final BitSet FOLLOW_entre_in_entre202 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_cellule_in_entre210 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_CELLULEG_in_cellule226 = new BitSet(new long[]{0x0000000000008000L});
    public static final BitSet FOLLOW_CHAINE_in_cellule228 = new BitSet(new long[]{0x0000000000000020L});
    public static final BitSet FOLLOW_CELLULED_in_cellule230 = new BitSet(new long[]{0x0000000000000002L});

}